<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('未出款数据')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<input type="hidden" name="type" value="0">
						<ul>
							<li>
								<label style="width: 80px">商户编号：</label>
								<input type="text" name="merno"/>
							</li>
							<li>
								<label style="width: 80px">结算卡号：</label>
								<input type="text" name="screen_num"/>
							</li>

							<li>
								<label style="width: 80px;">出款流水号：</label>
								<input type="text" name="settle_serial"/>
							</li>
							<!--<li>
								<label>出款状态：</label>
								<select name="settle_state">
									<option value="">请选择</option>
									<option value="1">出款成功</option>
									<option value="-2">出款失败</option>
									<option value="-3">冻结</option>
									<option value="0">待处理（默认）</option>
									<option value="-1">已上送</option>
								</select>
							</li>-->
							<li>
								<label style="width: 80px">备注：</label>
								<input type="text" name="remarks"/>
							</li>
							<li>
								<label style="width: 80px">账户名称：</label>
								<input type="text" name="screen_name"/>
							</li>
							<li>
								<label style="width: 100px">资深总监编号：</label>
								<input type="text" name="senior_num"/>
							</li>
							<li>
								<label style="width: 100px">资深总监名称：</label>
								<input type="text" name="senior_name"/>
							</li>
							<li>
								<label style="width: 80px">商户类别：</label>
								<select name="mer_category">
									<option value="">请选择</option>
									<option value="0">标准类</option>
									<option value="1">优惠类</option>
									<option value="2">减免类</option>
								</select>
							</li>
							<li>
								<label style="width: 80px">商户类型：</label>
								<select name="mer_type">
									<option value="">请选择</option>
									<option value="0">传统商户</option>
									<option value="1">手刷商户</option>
								</select>
							</li>

							<li>
								<label style="width: 80px">交易类型：</label>
								<select name="transaction_type">
									<option value="">请选择</option>
									<option value="0">线下交易</option>
									<option value="1">线上交易</option>
								</select>
							</li>
							<li>
								<label style="width: 80px">结算类型：</label>
								<select name="settle_type">
									<option value="">请选择</option>
									<option value="00">商户</option>
									<option value="01">代理</option>
								</select>
							</li>
							<li>
								<label>账户类型：</label>
								<select name="wa_type">
									<option value="">请选择</option>
									<option value="98">分润账户2</option>
									<option value="99">返现账户2</option>
								</select>
							</li>

							<li class="select-time">
								<label style="width: 80px">日期：</label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="mindDate"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="maxDate"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success single disabled" onclick="updateBank()" shiro:hasPermission="merchantInfo:merchantInfo:updateBank">
					<i class="fa fa-edit"></i> 修改结算信息
				</a>
				<!--<a class="btn btn-success" onclick="queryUnknown()" shiro:hasPermission="merchantInfo:merchantInfo:updateBank">
					<i class="fa fa-edit"></i> 发起未知查询
				</a>-->
				<a class="btn btn-success" onclick="errorAgain()" shiro:hasPermission="merchantInfo:merchantInfo:updateBank">
					<i class="fa fa-edit"></i> 重新出款
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" class="table text-nowrap"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var prefix = ctx + "settleInfo/settleInfo";

		$(function()  {
            var options = {
                url: prefix + "/errorPayList",
	            clickToSelect:true,
                columns: [
					{
						checkbox: true
					},
				{
					field : 'MERNO',
					title : '商户编号',
					width: "180",
					formatter:function (value, row, index) {
						return value+$.table.tooltip('[备注]'+row.REMARKS,4);
					}
				},
				{
					field : 'MER_NAME',
					title : '商户名称',
					formatter:function (value, row, index) {
						return $.table.tooltip(value,4);
					}
				},
				{
					field : 'MER_CATEGORY',
					title : '商户类别',
					formatter: function(value, row, index) {
						if ("0"==value){
							return '<span style="color:blue;">标准类</span>';
						}else if("1"==value){
							return '<span style="color:green;">优惠类</span>';
						}else if("2"==value){
							return '<span style="color:green;">减免类</span>';
						}else{
							return '<span style="color:red;">未知</span>';
						}
					}
				},
				{
					//商户类型(0-传统商户、1-手刷(MPOS)商户、2-机构商户、3-闪银Pro 4- 理财商户、5-电签商户) -1 未知商户
					field : 'MER_TYPE',
					title : '商户类型',
					formatter: function(value, row, index) {
						if ("0" == value){
							return '<span style="color:blue;">传统商户</span>';
						} else if("1" == value){
							return '<span style="color:green;">手刷商户</span>';
						} else if("2" == value){
							return '<span style="color:green;">机构商户</span>';
						} else if("3" == value){
							return '<span style="color:green;">闪银Pro</span>';
						} else if("4" == value){
							return '<span style="color:green;">理财商户</span>';
						} else if("5" == value){
							return '<span style="color:green;">电签商户</span>';
						} else if("-1" == value){
							return '<span style="color:green;">未知商户</span>';
						}else{
							return '<span style="color:red;">未知商户</span>';
						}
					}
				},
				{
					field : 'NATURE',
					title : '账户类型(出款)',
					formatter: function(value, row, index) {
						if ("1"==value){
							return '<span style="color:blue;">对公</span>';
						}else if("2"==value){
							return '<span style="color:green;">对私</span>';
						}else{
							return '<span style="color:red;">未知</span>';
						}
					}
				},
				{
				    field : 'BANK_NAME',
				    title : '开户行名称(出款)',
					formatter:function (value, row, index) {
						return $.table.tooltip(value,4);
					}
				},
				{
					field : 'SCREEN_NAME',
					title : '结算人(出款)'
				},
				{
					field : 'SCREEN_NUM',
					title : '结算卡(出款)'
				},
				{
					field : 'SCREEN_NAME_M',
					title : '结算人(结算)'
				},
				{
					field : 'SHOW_SCREENNUM',
					title : '结算卡(结算)'
				},
				{
					field : 'TMONEY',
					title : '结算金额(元)',
					formatter: function(value, row, index) {
						if (row.SETTLE_TYPE == '00'){
							return $.table.rmbFormatter(value);
						} else {
							return $.table.rmbFormatter(value/100);
						}
					}
				},
				{
					field : 'AMOUNT',
					title : '总交易金额(元)',
					formatter: function(value, row, index) {
						if (row.SETTLE_TYPE == '00'){
							return $.table.rmbFormatter(value);
						} else {
							return $.table.rmbFormatter(value/100);
						}
					}
				},

				{
					field : 'CHARGE',
					title : '总手续费(元)',
					formatter: function(value, row, index) {
						if (row.SETTLE_TYPE == '00'){
							return $.table.rmbFormatter(value);
						} else {
							return $.table.rmbFormatter(value/100);
						}
					}
				},
				{
					field : 'COUNTS',
					title : '总笔数'
				},
				{
					field : 'AUDITDATE',
					title : '出款日期'
				},
				{
					field : 'SETTLE_STATE',
					title : '出款状态',
					formatter: function(value, row, index) {
						if ("0"==value){
							return '<span style="color:blue;">待处理</span>';
						}else if("1"==value){
							return '<span style="color:green;">出款成功</span>';
						}else if("-2"==value){
							return '<span style="color:red;">出款失败</span>';
						}else if("-3"==value){
							return ' <span style="color:green;">冻结</span>';
						}else if("1"==value){
							return ' <span style="color:green;">已上送</span>';
						}else{
							return ' <span style="color:red;">出款失败</span>';
						}
					}
				},

				{
					field : 'SETTLE_SERIAL',
					title : '出款流水号'
				},{
						field : 'ACC_TYPE',
						title : '账户类型'
					}]
            };
            $.table.init(options);
        });

		/**
		 * 修改结算
		 */
		function updateBank() {
			var settleState = $.table.selectColumns("SETTLE_STATE");
			var settleSerial = $.table.selectColumns("SETTLE_SERIAL");
			if ($.common.isEmpty(settleState)) {
				$.modal.alertWarning("请至少选择一条记录");
				return;
			}
			if (settleState != '-2'){
				$.modal.alertWarning("出款失败才可修改结算信息");
				return;
			}
			$.modal.open("修改结算信息",prefix + "/updateBank/" + settleSerial,'1200','600');
		}

		/**
		 * 发起未知查询
		 */
		function queryUnknown() {
			$.modal.confirm("确认发起未知查询?", function() {
				$.operate.submit(prefix + "/queryUnknown", "post", "json");
			});
		}


		/**
		 * 重新出款
		 */
		function errorAgain() {
			$.modal.confirm("确认重新出款?", function() {
				var arrays = $.table.selectColumns("ID");
				if ($.common.isEmpty(arrays)){
					$.modal.msgError("请至少选择一条记录");
					return;
				}
				var data = {"ids":arrays.toString()};
				$.operate.submit(prefix + "/errorAgain", "post", "json",data);
			});
		}

    </script>
</body>
</html>